package com.xuxiao.mapper;

import com.xuxiao.common.ReturnNameAndCardID;
import com.xuxiao.common.TransCord;
import com.xuxiao.entrty.TransInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TransInfoMapper {
    @Update("UPDATE  cardinfo set balance=balance-#{transMoney} WHERE cardID=#{cardID}")
    void plus(ReturnNameAndCardID returnNameAndCardID);

    @Update("UPDATE  cardinfo set balance=balance+#{transMoney} WHERE cardID=#{transID}")
    void reduce(ReturnNameAndCardID returnNameAndCardID);

    @Insert("INSERT transinfo (transDate, cardID, TransID, transType, transMoney, remark) VALUES (#{transDate},#{cardID},#{transID},#{transType},#{transMoney},#{remark})")
    void addRecord(ReturnNameAndCardID returnNameAndCardID);

    @Delete("DELETE FROM transinfo where id=#{id}")
    void deleteByID(String id);

    @Select("SELECT * FROM alltrans")
    List<TransCord> SelectAll();

    List<TransCord> SelectById(String id);

    List<TransCord> SelectByName(String name);

    @Select("SELECT * from alltrans where gocustomid=#{name}")
    List<TransCord> SelectIncome(String name);
}
